<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>错误信息捕获与处理</title>
</head>
<body>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.open('GET', 'data.txt', true);
        xhr.send();
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                if (xhr.status >= 200 && xhr.status <= 300) {
                    console.log("Request successful:",xhr.responseText);
                } else {
                    console.error('Request failed:', xhr.statusText);
                }
            }
        };
        xhr.send();
    </script>
</body>
</html>